<?php
$params = array_merge(
    require __DIR__ . '/../../common/config/params.php',
    require __DIR__ . '/../../common/config/params-local.php',
    require __DIR__ . '/params.php',
    require __DIR__ . '/params-local.php'
);

return [
    'id' => 'app-backend',
    'basePath' => dirname(__DIR__),
    'controllerNamespace' => 'backend\controllers',
    'bootstrap' => ['log'],
    'modules' => [],
    'components' => [
        'request' => [
            'csrfParam' => '_csrf-backend',
            'parsers' => [
                'application/json' => 'yii\web\JsonParser',
                'text/json' => 'yii\web\JsonParser',
            ],
        ],
        'response' => [
            'format' => 'json',
            'class' => 'yii\web\Response',
            'on beforeSend' => function ($event) {
                $response = $event->sender;
                $response->data = [
                    'success' => $response->isSuccessful,
                    'code' => $response->getStatusCode(),
                    'message' => $response->statusText,
                    'data' => $response->data,
                ];
                $response->statusCode = 200;
            },
        ],
        'user' => [
            'identityClass' => 'common\models\User',
            'enableAutoLogin' => true,
            'identityCookie' => ['name' => '_identity-backend', 'httpOnly' => true],
        ],

        'session' => [
            // this is the name of the session cookie used for login on the backend
            'name' => 'advanced-backend',
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
        'cache' => [
            'class' => 'yii\caching\FileCache',
        ],
        'urlManager' => [
            'class'=>'common\components\UrlManager',
            'enablePrettyUrl' => true,
            'enableStrictParsing' => true,
            'showScriptName' => false,
            'rules' => [
                ['class' => 'yii\rest\UrlRule',
                    'controller' => 'user'
                ],
                //cpy
                'login' => 'login/login',
                'get_pic_code' => 'login/get-pic-code',
                'logout' => 'login/logout',
                'admin_list' => 'admin/get-list',
                'admin_add' => 'admin/admin-add',
                'admin_edit' => 'admin/admin-edit',
                'edit_password' => 'admin/edit-password',
                'get_admin_info' => 'admin/get-admin-info',
                'del_admin' => 'admin/del-admin',
                'batch_del_admin' => 'admin/batch-del-admin',

                'video_list' => 'video/get-list',
                'video_detail' => 'video/detail',
                'video_add' => 'video/add-info',
                'video_edit' => 'video/edit-info',
                'video_del' => 'video/delete-info',
                'video_batch_del' => 'video/batch-del-info',

                'info_list' => 'info/get-list',
                'info_detail' => 'info/detail',
                'info_add' => 'info/add-info',
                'info_edit' => 'info/edit-info',
                'info_del' => 'info/delete-info',
                'info_batch_del' => 'info/batch-del-info',
                //hy
                'GET  get_team_list' => 'team/get-team-list', //团队介绍列表以及下载
                'POST add_team_info' => 'team/add-team-info', //增加团队成员
                'POST edit_team_info' => 'team/edit-team-info',//编辑团队成员
                'POST delete_team_info' => 'team/delete-team-info', // 删除团队成员
                'POST batch_del_team_info' => 'team/batch-del-team-info', // 批量删除团队成员

                'GET  get_project_list' => 'project/get-project-list', //项目列表以及下载
                'GET  get_project_detail' => 'project/get-project-detail', //获取项目详情
                'POST add_project_info' => 'project/add-project-info', //增加项目
                'POST edit_project_info' => 'project/edit-project-info',//编辑项目
                'POST delete_project_info' => 'project/delete-project-info', // 删除项目
                'POST batch_del_project_info' => 'project/batch-del-project-info', // 批量删除项目

                'GET  get_banner_list' => 'banner/get-banner-list', //banner列表以及下载
                'POST add_banner_info' => 'banner/add-banner-info', //增加banner
                'POST edit_banner_info' => 'banner/edit-banner-info',//编辑banner
                'POST delete_banner_info' => 'banner/delete-banner-info', // 删除banner
                'POST batch_del_banner_info' => 'banner/batch-del-banner-info', // 批量删除banner

                'GET  get_config_info' => 'config/get-config-info', //获取网站配置详情
                'POST  edit_config_info' => 'config/edit-config-info', //编辑网站配置详情


            ],
        ]

    ],
    'params' => $params,
];
